/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package zpsb.jsf;

import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import zpsb.model.Product;
import zpsb.session.ImionaCounter;

/**
 *
 * @author School
 */
@ManagedBean
@SessionScoped
public class IndexController {

    @EJB
    private ImionaCounter imionaCounter;
   
    
    private String imie;
    private String helloString;

    public String getHelloString() {
        imionaCounter.increase();
        return "Hello "+imie+"! Jestes "+imionaCounter.getCounter();
    }

    

    public String getImie() {
        return imie;
    }

    public void setImie(String imie) {
        this.imie = imie;
    }
    
    /**
     * Creates a new instance of IndexController
     */
    public IndexController() {
    }
    public void printProducts(){
        System.out.println("Działa");
        List<Product> list =  imionaCounter.getProducts();
        for (Product product : list){
            System.out.println(product.getProductCode()+" "+product.getDescription());
        }
        
    }
    public void refresh(){}
    
    public String go(){ return "go";}
}

